<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class User_model extends CI_Model {

    public function __construct()
    {
            $this->load->database();
    }

    public function get_user($slug = FALSE)
    {
        if ($slug === FALSE)
        {
            $query = $this->db->get('user');
            return $query->result_array();
        }

        $query = $this->db->get_where('user', array('id' => $slug));
        return $query->row_array();
    }
    
    public function set_user(){
        $this->load->helper('url');
	
	//$slug = url_title($this->input->post('userid'), 'dash', TRUE);
	
	$data = array(
            'userid' => $this->input->post('userid'),
            'email' => $this->input->post('email'),
            'password' => $this->input->post('password'),
            'group_access' => 'read_only'
	);
	
	return $this->db->insert('user', $data);
    }
}
?>
